//
//  UUProductPackagePicker.m
//  UUCharterSupplier
//
//  Created by ZhangAo on 27/02/2018.
//  Copyright © 2018 UUCharter. All rights reserved.
//

#import "UUProductPackagePicker.h"

@interface UUProductPackagePicker ()

@end

@implementation UUProductPackagePicker

static UIViewController *_picker;
+ (UIViewController *)pickerWithPackageType:(UUProductPackageType)packageType
                              completeBlock:(void (^)(NSNumber *))completeBlock {
    UUProductPackagePicker *picker = [self packageListWithPackageType:packageType];
    if (packageType == UUProductPackageTypeDay) {
        picker.title = @"请选择套餐";
    } else {
        picker.title = @"请选择线路";
    }
    WEAK_SELF();
    picker.didSelectPackageBlock = ^(NSNumber *packageId) {
        completeBlock(packageId);
        [weakSelf dismiss];
    };
    picker.navigationItem.leftBarButtonItem = [UIBarButtonItem barButtonItemWithTitle:@"取消"
                                                                               target:self
                                                                             selector:@selector(dismiss)];
    _picker = picker;
    return [[UINavigationController alloc] initWithRootViewController:picker];
}

+ (void)dismiss {
    [_picker dismissViewControllerAnimated:YES completion:nil];
    _picker = nil;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
